/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package titanisu.basicMathModule1.FractionToPercentage;

import java.util.ArrayList;
import java.util.Random;

/**
 *
 * @author Balaji
 */
public class QuestionGeneratorAddSub {

    ArrayList quest = new ArrayList();

    private void setQ(ArrayList arlst) {
        this.quest = arlst;
    }

    public ArrayList getQuest() {
        return quest;
    }

    public void setQuest(ArrayList quest) {
        this.quest = quest;
    }

    public String getQuestions() {
        int w = (new Random()).nextInt(9) + 1, x = (new Random()).nextInt(9) + 1;
        titanisu.templates.helperClasses.VariablesHelper mh = new titanisu.templates.helperClasses.VariablesHelper();
        int[] an;
        int den = -1;
        int nom , denom;
        
        float a = (float)w/x;
        System.out.println("a = " + a);
        
        quest.add(0, "<math>   <mfrac>  <mi> " + w + " </mi>  <mi> " + x + " </mi>  </math>  ");
        a*=100;
        
        String solution = ""+a;
        
                    int decLoc = solution.indexOf(".");
            if (decLoc != -1) {
                if (solution.substring(decLoc).length() > 4) {
                    solution = solution.substring(0, decLoc + 3);
                }
            }

        
        quest.add(1, "<math>   <mi> " + solution + " % </mi>  </math>  ");
        
        setQ(quest);
        System.out.println(" quest set in questionGenerator is " + quest);
        return (String) quest.get(0);
    }

    /**
     * Gives the answers
     *
     * @return
     */
    public String getAnswer() {
        return (String) quest.get(1);
    }
}
